<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <script>
    //-----------第一种------------------
    let arr1 = [[222, 333, 444], [55, 66, 77], { a: 1 }];
    arr1 += '';   //这一步就把a=1变味了[object Object]
    arr1 = arr1.split(',');
    console.log(arr1);
    let arr5 = [1, 2, [3, 4, [5, 6]]];
    arr5 += '';
    arr5 = arr5.split(',');
    arr5 = arr5.map(Number)
    console.log(arr5);
    //-----------第二种------------------
    let arr2 = [1, 2, [3, 4]];
    console.log(arr2.flat());
    // [1, 2, 3, 4]

    let arr3 = [1, 2, [3, 4, [5, 6]]];
    console.log(arr3.flat());
    // [1, 2, 3, 4, [5, 6]]

    let arr4 = [1, 2, [3, 4, [5, 6]]];
    console.log(arr4.flat(2));
    // [1, 2, 3, 4, 5, 6]

    //使用 Infinity 作为深度，展开任意深度的嵌套数组
    console.log(arr4.flat(Infinity));
    // [1, 2, 3, 4, 5, 6]

  </script>
</body>

</html>